﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BluePortal.Medias.Core;

namespace BluePortal.QuikStart.UserControls
{
    public partial class AddTag : System.Web.UI.UserControl
    {
        public Guid VideoId;

        private bool addAction = false;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ViewState["VideoId"] = VideoId;
                odsTag.SelectParameters["ID"].DefaultValue = VideoId.ToString();
            }
            
        }

        protected void AddTagClick(object sender, EventArgs e)
        {
            new BCTag().Add(new Video() { ID = (Guid)ViewState["VideoId"] }, tbTag.Text);
            rpTags.DataBind();
            tbTag.Text = String.Empty;
            addAction = true;

        }

        protected void rpTags_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "delete")
            {
                new BCTag().Remove((Guid)ViewState["VideoId"], new Guid((String)e.CommandArgument));
                rpTags.DataBind();
            }
        }
    }
}